package testsw.order.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.github.pagehelper.PageInfo;
import com.testsw.order.pojo.Reporttable;
import entity.Result;
import entity.StatusCode;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import testsw.order.feign.ReporttableFeign;

import java.util.List;

;

/****
 * @Author: zhangsan
 * @Description:
 * @Date: 2020-03-20 09:36:48
 *****/
@Api(value = "ReporttablefeignController")
@RestController
@RequestMapping("/feignreporttable")
@CrossOrigin
public class ReporttableFeignController {

    @Autowired
    private ReporttableFeign reporttableFeign;

    /***t
     * Reporttable分页条件搜索实现
     * @param reporttable
     * @param page
     * @param size
     * @return
     */
    @ApiOperation(value = "Reporttable条件分页查询",notes = "分页条件查询Reporttable方法详情",tags = {"ReporttableController"})
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "page", value = "当前页", required = true, dataType = "Integer"),
            @ApiImplicitParam(paramType = "path", name = "size", value = "每页显示条数", required = true, dataType = "Integer")
    })
    @PostMapping(value = "/search/{page}/{size}" )
    public Result<PageInfo> findPage(@RequestBody(required = false) @ApiParam(name = "Reporttable对象",value = "传入JSON数据",required = false) Reporttable reporttable, @PathVariable  int page, @PathVariable  int size){
        //调用ReporttableService实现分页条件查询Reporttable
        return  reporttableFeign.findPage(reporttable, page, size);

    }

    /***
     * Reporttable分页搜索实现
     * @param page:当前页
     * @param size:每页显示多少条
     * @return
     */
    @ApiOperation(value = "Reporttable分页查询",notes = "分页查询Reporttable方法详情",tags = {"ReporttableController"})
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "page", value = "当前页", required = true, dataType = "Integer"),
            @ApiImplicitParam(paramType = "path", name = "size", value = "每页显示条数", required = true, dataType = "Integer")
    })
    @GetMapping(value = "/search/{page}/{size}" )
    public Result<PageInfo> findPage(@PathVariable  int page, @PathVariable  int size){
        //调用ReporttableService实现分页查询Reporttable
         return  reporttableFeign.findPage(page, size);

    }

    /***
     * 多条件搜索品牌数据
     * @param reporttable
     * @return
     */
    @ApiOperation(value = "Reporttable条件查询",notes = "条件查询Reporttable方法详情",tags = {"ReporttableController"})
    @PostMapping(value = "/search" )
    public Result<List<Reporttable>> findList(@RequestBody(required = false) @ApiParam(name = "Reporttable对象",value = "传入JSON数据",required = false) Reporttable reporttable){
        //调用ReporttableService实现条件查询Reporttable
        return reporttableFeign.findList(reporttable);
    }

    /***
     * 根据ID删除品牌数据
     * @param id
     * @return
     */
    @ApiOperation(value = "Reporttable根据ID删除",notes = "根据ID删除Reporttable方法详情",tags = {"ReporttableController"})
    @ApiImplicitParam(paramType = "path", name = "id", value = "主键ID", required = true, dataType = "Integer")
    @DeleteMapping(value = "/{id}" )
    public Result delete(@PathVariable Integer id){
        //调用ReporttableService实现根据主键删除
        return reporttableFeign.delete(id);

    }

    /***
     * 修改Reporttable数据
     * @param reporttable
     * @param id
     * @return
     */
    @ApiOperation(value = "Reporttable根据ID修改",notes = "根据ID修改Reporttable方法详情",tags = {"ReporttableController"})
    @ApiImplicitParam(paramType = "path", name = "id", value = "主键ID", required = true, dataType = "Integer")
    @PutMapping(value="/{id}")
    public Result update(@RequestBody @ApiParam(name = "Reporttable对象",value = "传入JSON数据",required = false) Reporttable reporttable,@PathVariable Integer id){
        //设置主键值
        reporttable.setId(id);
        //调用ReporttableService实现修改Reporttable
        return reporttableFeign.update(reporttable,id);
    }

    /***
     * 新增Reporttable数据
     * @param reporttable
     * @return
     */
    @ApiOperation(value = "Reporttable添加",notes = "添加Reporttable方法详情",tags = {"ReporttableController"})
    @PostMapping
    public Result add(@RequestBody  @ApiParam(name = "Reporttable对象",value = "传入JSON数据",required = true) Reporttable reporttable){
        //调用ReporttableService实现添加Reporttable
        return reporttableFeign.add(reporttable);

    }

    /***
     * 根据ID查询Reporttable数据
     * @param id
     * @return
     */
    @ApiOperation(value = "Reporttable根据ID查询",notes = "根据ID查询Reporttable方法详情",tags = {"ReporttableController"})
    @ApiImplicitParam(paramType = "path", name = "id", value = "主键ID", required = true, dataType = "Integer")
    @GetMapping("/reporttableFeign/{id}")
    public Result<Reporttable> findById(@PathVariable Integer id){
        //调用ReporttableService实现根据主键查询Reporttable
        return reporttableFeign.findById(id);

    }

    /***
     * 查询Reporttable全部数据
     * @return
     */
    @ApiOperation(value = "查询所有Reporttable",notes = "查询所Reporttable有方法详情",tags = {"ReporttableController"})
    @GetMapping
    public Result<List<Reporttable>> findAll(){
        //调用ReporttableService实现查询所有Reporttable
        return reporttableFeign.findAll();
    }
}
